{extend name="common:base"/}
{block name="body"}
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-12">
        <h2>用户</h2>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="panel blank-panel panel-heading background-fff">
                <div class="panel-options">
                    <ul class="nav nav-tabs">
                        <li class='active'><a href="{:\\think\\Url::build('AuthManager/access',['group_id'=>$group_id])}">访问授权</a></li>
                        <li class=""><a href="{:\\think\\Url::build('AuthManager/user',['group_id'=>$group_id])}">用户授权</a></li>
                        <li class="pull-right">
                            <div class="btn-group pull-right">
                                <button data-toggle="dropdown" class="btn btn-default dropdown-toggle">选择用户组
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    {volist name="auth_group" id="vo"}
                                    <li><a href="{:\\think\\Url::build('AuthManager/access',['group_id'=>$vo['id']])}" class="{eq name='vo.id' value='$this_group.id'}font-bold{/eq}">{$vo.title}</a></li>
                                    {/volist}
                                </ul>
                            </div>
                        </li>
                    </ul>
                </div>
                <div class="panel-body padding-lr-0">
                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <form action="{:\\think\\Url::build('AuthManager/rulesArrayUpdate')}" method="post" class="auth-form">
                                {volist name="node_list" id="node" }
                                <div class="panel panel-default all">
                                    <div class="panel-heading">                                        
                                        <label class="m-b-none"><input type="checkbox" name="rules[]" class="auth_rules rules_all " value="<?php echo $main_rules[$node['url']] ?>"> {$node.title}管理</label>                                            
                                    </div>
                                    {present name="node['child']"}
                                    <div class="panel-body padding-b-0 rule_check">
                                        {volist name="node['child']" id="child" }
                                        <div class='rule_check'>
                                            <label><input type="checkbox" class="auth_rules rules_row " name="rules[]" value="<?php echo $auth_rules[$child['url']] ?>"/> {$child.title}</label>
                                            {notempty name="child['operator']"}
                                            <div class="checkbox child_row">
                                                <span>&nbsp;&nbsp;&nbsp;</span>
                                                {volist name="child['operator']" id="op"}
                                                <label><input type="checkbox" class="auth_rules " name="rules[]" value="<?php echo $auth_rules[$op['url']] ?>"/> {$op.title}</label>
                                                {/volist}
                                            </div>
                                            {/notempty}
                                            <span class="hr-line-dashed"></span>
                                        </div>
                                        {/volist}
                                    </div>
                                    {/present}
                                </div>
                                {/volist}
                                <div class="panel">
                                    <input type="hidden" name="id" value="{$this_group.id}" />
                                    <button type="submit" class="btn btn-w-m btn-primary ajax-post" target-form="auth-form">确 定</button>
                                    <button class="btn btn-w-m btn-default retreat">取消</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    +function ($) {
        var rules = [{$this_group.rules}];
        $('.auth_rules').each(function () {
            if ($.inArray(parseInt(this.value, 10), rules) > -1) {
                $(this).prop('checked', true);
            }
            if (this.value == '') {
                $(this).closest('span').remove();
            }
        });
        //全选节点
        $('.rules_all').on('change', function () {
            $(this).closest('.all').find('.rule_check').find('input').prop('checked', this.checked);
        });
        $('.rules_row').on('change', function () {
            $(this).closest('.rule_check').find('.child_row').find('input').prop('checked', this.checked);
        });
    }(jQuery);

    highlight_subnav("{:\\think\\Url::build('auth_manager/index')}");
</script>
{/block}